/*
  Copyright (C) 2011, Kyungjoo Kim
  
  This file is part of UHM (Unassembled HyperMatrix) sparse direct solver.
  
  All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  Also add information on how to contact you by electronic and paper mail.
  
  
  Kyungjoo Kim
  iamkyungjoo@gmail.com
*/
#ifndef UHM_INTERF_WSMP_HXX
#define UHM_INTERF_WSMP_HXX

namespace uhm {

  namespace interf {
    typedef class Sparse_* Sparse;
    typedef class WSMP_*   WSMP;

    // ----------------------------------------------------------------
    // ** PARDISO
    class WSMP_ {
    private:
    protected:

      int datatype, show_n_rhs;
    
      // parameters - see manual
      int    iparm[64];
      double dparm[64];
    
      // matrix CSR format
      int n_dof, n_rhs, n_nz;
      std::vector<int> ia, ja, perm, invp;
      std::vector<double> a, b, r, x;

      void _init(int datatype) {
        assert(datatype == UHM_REAL ||
               datatype == UHM_COMPLEX);
        this->datatype = datatype;
        this->show_n_rhs = 0;
      }
    
    public:

      // methods
      WSMP_() { _init(UHM_REAL); }
      WSMP_(int datatype) { _init(datatype); }
      virtual ~WSMP_() { }

      bool export_matrix(Mesh m);

      void disp();
      void disp( FILE *stream );

      bool is_complex();

      void set_show_n_rhs(int show_n_rhs);
      void set_iparm(int idx, int val);
      void set_dparm(int idx, double val);
      void set_sparse_matrix(Sparse sp);

      int    get_iparm(int idx);
      double get_dparm(int idx);

      int  get_n_dof();
      int  get_n_rhs();
      int  get_n_nonzero();

      bool validate_sparse_matrix();
      int  run();

      bool init();
      bool analyze();
      bool decompose();
      bool solve();
      bool refine();
      bool finalize();
    };

    // ----------------------------------------------------------------
  }
}

#endif
